from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtGui import QIcon

# import time

# from common.libs.Log import logging
# from common.libs.MathFunc import MathFunc

from ui.app import Ui_MainWindow
from ui import images

from widgets.mqtt.MqttTestWidget import MqttTestWidget
from widgets.device.DeviceWidget import DeviceWidget


class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        # self.setWindowState(Qt.WindowMaximized)
        self.setWindowIcon(QIcon(':icons/images_rc/app.png'))
        self.setWindowTitle("辐射场控制")
        # 窗口初始化
        self.widgetsInit()
        # Act动作初始化
        self.actInit()
        # 菜单栏初始化
        self.menuInit()
        # 工具栏初始化
        self.toolBarInit()
        # 信号绑定
        self.signalInit()

    def widgetsInit(self):
        self.mqttTestWidget = MqttTestWidget()
        self.devieWidget = DeviceWidget()
        self.verticalLayout_device.addWidget(self.devieWidget)
        self.verticalLayout_mqtt.addWidget(self.mqttTestWidget)
        pass
        # self.taskManager = TaskRunManager()

    def actInit(self):
        pass
        # self.comSetAct = QAction("&通信串口", self, triggered=self.comSetWidget.show)

    def menuInit(self):
        pass
        # self.fileMenu = self.menuBar().addMenu("&文件")
        # self.fileMenu.addAction(self.newProjectAct)

    def toolBarInit(self):
        pass
        """ 工具栏初始化 """
        # # 创建工具栏
        # self.toolbar = self.addToolBar('工具栏')
        # # 设置工具栏显示文字说明
        # self.toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        # self.toolbar.addAction(self.stopTaskAct)

    def signalInit(self):
        pass


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    app.exec_()
